<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>药剂领取管理</title>
    <!-- jquery - boot -库文件 -->
    <script src="__PUBLIC__/script/jquery.1.11.1.js"></script>
    <script src="__PUBLIC__/script/bootstrap.min.js"></script>
    <!-- Bootstrap -->
    <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap -->
    <!-- font awesome -->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/FontAwesome/css/font-awesome.min.css">
    <script src="__PUBLIC__/script/common.js"></script>
    <!--easyui包含文件-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/easyui1.5.3/themes/material/easyui.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/easyui1.5.3/themes/icon.css">
    <script type="text/javascript" src="__PUBLIC__/plugins/easyui1.5.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/plugins/easyui1.5.3/locale/easyui-lang-zh_CN.js"></script>
    <!--layer-->
    <script type="text/javascript" src="__PUBLIC__//plugins/layer/layer.js"></script>
    <!-- 自定义 css -->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/reset.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/common.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/style.css">
    <!-- end easyui -->
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="__PUBLIC__/script/html5shiv.js"></script>
    <script src="__PUBLIC__/script/respond.js"></script>
    <![endif]-->
</head>

<body>
    <include file="Public/header" />
    <!-- indexmain -->
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12 mainbox" id="mainbox">
                <!--menubegin-->
                <div class="datamenubox" id="leftmenu">
                    <div class="menuhead">药品领取</div>
                    <!-- treein -->
                    <div class="treein" id="menuin">
                        <ul class="list-group smenu">
                            <volist name="menulist" id="vo">
                                <a href="{:U($vo[url])}"><li class="list-group-item" id="{$vo.url}"><i class="fa fa-angle-right"></i>{$vo.name}</li></a>
                            </volist>
                        </ul>
                    </div>
                </div>
                <!--menuend-->
                <!--mainboxbegin-->
                <div class="col-md-12 rights" id="right">
                    <!-- 位置导航 -->
                    <ol class="breadcrumb">
                        <li class="active">首页</li>
                        <li class="active">药品领取</li>
                        <li class="active">领取管理</li>
                    </ol>
                    <!-- 筛选 -->
                    <div class="searchitem">
                        <div class="row">
                            <div class="col-md-12">
                                <input class="easyui-combobox" name="q_lb" id="q_lb" style="width:300px" data-options="label:'类别名称：',valueField:'id',textField:'text',panelHeight:'120'">
                            </div>
                        </div>
                        <div class="blank10"></div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="btnin">
                                    <button class="btn btn-danger" id="querybtn">查询</button>
                                    <!-- <button class="btn btn-info" id="addbtn">添加</button>
                                    <button class="btn btn-info" id="updatebtn">编辑</button> -->
                                    <button class="btn btn-info" id="delbtn">删除</button>
                                </div>
                            </div>
                        </div>
                        <!-- end 筛选 -->
                    </div>
                    <!-- listtable -->
                    <div>
                        <!-- gridview row -->
                        <table id="dg"></table>
                        <!-- end gridview row -->
                    </div>
                    <!--mainboxend-->
                </div>
            </div>
        </div>
        <!-- indexmain end -->
        <!-- modals -->
        <div id="w" class="easyui-window" title="药品领取明细" data-options="modal:true,closed:true" style="width:500px;height:500px;padding:15px;display:none;">
            <table id="dgmx"></table>
            <div class="blank10"></div>
            <input class="easyui-textbox" name="mc_x" id="mc_x" style="width:200px" data-options="label:'名称：',readonly:true">
            <input class="easyui-numberbox" name="jl_x" id="jl_x" style="width:150px" data-options="label:'剂量：',precision:1">
            <input type="hidden" id="hidlqid" name="hidlqid" />
            <input type="hidden" id="hidmxid" name="hidmxid" />
            <button class="btn btn-info" id="xgjl">修改</button>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->
    <!-- /modals -->
    <include file="Public/footer" />
    <script>
    $(document).ready(function() {
        //初始化页面
        $('#lqgl').addClass('on');
        loaddg();
        LoadDDL('q_lb','YJLB');
    });
    //加载数据列表
    function loaddg() {
        $('#dg').datagrid({
            loadMsg: '正在查询，请稍后...',
            title: '双击某行数据弹出详情页面，进行修改',
            height: $(window).height() - 300,
            url: '{:U(\'querylqgl\')}',
            queryParams: {
                lb: $('#q_lb').combobox('getValue')
            },
            nowrap: false,
            striped: true,
            collapsible: false,
            loadMsg: '正在加载，请稍后。。。',
            remoteSort: false,
            singleSelect: true,
            pageSize: 100,
            idField: 'id',
            pagination: true,
            rownumbers: true,
            pagination: true,
            pageNumber: 1,
            pageSize: 20,
            pageList: [20, 40, 80, 160],
            fitColumns: true,
            columns: [
                [{
                    field: 'lb',
                    title: '类别',
                    width: 100
                }, {
                    field: 'user',
                    title: '申请人',
                    width: 100
                }, {
                    field: 'sj',
                    title: '时间',
                    width: 100
                },{
                    field: 'bz',
                    title: '备注',
                    width: 150
                }]
            ],
            onDblClickRow:function(index,row){
                $('#dgmx').datagrid({
                    loadMsg: '正在查询，请稍后...',
                    title: '',
                    height: $('#w').height() - 50,
                    url: '{:U(\'querylqglmx\')}',
                    queryParams: {
                        lqid: row.id
                    },
                    nowrap: false,
                    striped: true,
                    collapsible: false,
                    loadMsg: '正在加载，请稍后。。。',
                    remoteSort: false,
                    singleSelect: true,
                    idField: 'id',             
                    fitColumns: true,
                    columns: [
                        [{
                            field: 'mc',
                            title: '名称',
                            width: 100
                        }, {
                            field: 'jl',
                            title: '剂量',
                            width: 100
                        }]
                    ],
                    onClickRow:function(index,row){
                        $('#mc_x').textbox('setValue',row.mc);
                        $('#jl_x').numberbox('setValue',row.jl);
                        document.getElementById("hidmxid").value=row.id;
                        document.getElementById("hidlqid").value=row.lqid;
                    }
                });
                $('#mc_x').textbox('setValue','');
                $('#jl_x').numberbox('setValue','');
                document.getElementById("hidmxid").value='';
                document.getElementById("hidlqid").value='';
                $('#w').window('open');
            }
        });
        $("#querybtn").click(function() {
            $('#dg').datagrid('load', { "lb": $('#q_lb').combobox('getValue')});
        });
    }
   
    //修改
    $('#xgjl').click(function(){
        var lqid = document.getElementById("hidlqid").value;
        var mxid = document.getElementById("hidmxid").value;
        if(lqid && mxid){
            layer.confirm('您确定要修改选中的数据？', {
                btn: ['是','否'] //按钮
                }, function(){
                    var option = {
                        type: "POST",
                        url: "{:U('xglqmxbyid')}",
                        data: {
                            id:mxid,
                            jl:$('#jl_x').numberbox('getValue')
                        },
                        success: function (data) {
                            layer.closeAll();
                            layer.msg(data);
                            $('#dgmx').datagrid('load', { "lqid": lqid});
                        }
                    };
                    $.ajax(option);
                }, function(){
                    layer.closeAll();
            });
        }
        else{
            layer.msg('请选择需要修改的数据！');
        }
    })
    </script>
</body>

</html>